//
//  XWXSqliteQueryCommand.m
//  XWXSqlite
//
//  Created by 许卫星 on 17/9/4.
//  Copyright © 2017年 wxxu. All rights reserved.
//

#import "XWXSqliteQueryCommand.h"
#import "XWXSqliteDataBasePool.h"

@interface XWXSqliteQueryCommand()
@property (nonatomic, copy) NSString *databaseName;
@property (nonatomic, strong, readwrite) NSMutableString *sqlString;
@property (nonatomic, weak, readwrite) XWXSqliteDataBase *database;
@end

@implementation XWXSqliteQueryCommand

- (instancetype)initWithDatabaseName:(NSString *)databaseName
{
    if (self = [super init]) {
        self.databaseName = databaseName;
    }
    return self;
}

- (instancetype)initWithDatabase:(XWXSqliteDataBase *)database
{
    if (self = [super init]) {
        self.database = database;
    }
    return self;
}

- (instancetype)resetQueryCommand
{
    self.sqlString = nil;
    return self;
}

- (NSMutableString *)sqlString
{
    if (_sqlString == nil) {
        _sqlString = [[NSMutableString alloc] init];
    }
    return _sqlString;
}

- (XWXSqliteDataBase *)database
{
    if (_database) {
        _database = [[XWXSqliteDataBasePool sharedInstance] databaseWithName:self.databaseName];
    }
    return _database;
}
@end
